//#########################################################
// 版权所有：鸽子游戏俱乐部
// 系统名称：鸽子游戏俱乐部-移动版
// 文件名称：resetPwdReducer.js
// 创建时间：2017年08月13日
// 创建人员：Lemo
// 功能说明：redux resetPwd
//#########################################################

'use strict';

import * as ActionTypes from '../actions/types';

const initialState = {
    username: '',
    validate: false,
    reseted: false,
    msg: ''
};

function resetPassword(state = initialState, action) {
    state = Object.assign({}, state, {
        reseted: false,
    });
    switch (action.type) {
        case ActionTypes.MY_RESETPWD_RESET_SUCCESS:
            return Object.assign({}, state, {
                validate: true,
                reseted: true,
                actionType: ActionTypes.MY_RESETPWD_RESET_SUCCESS
            });
        case ActionTypes.MY_RESETPWD_RESET_FAILED:
            return Object.assign({}, state, {
                validate: true,
                reseted: false,
                msg: action.msg,
                actionType: ActionTypes.MY_RESETPWD_RESET_FAILED
            });
        case ActionTypes.MY_RESETPWD_VALIDATE_FAILED:
            return Object.assign({}, state, {
                validate: false,
                reseted: false,
                msg: action.msg,
                actionType: ActionTypes.MY_RESETPWD_VALIDATE_FAILED
            });
        case ActionTypes.LOGOUT_SUCCESS:
        case ActionTypes.LOGOUT_FAILED:
            return initialState;
        default:
            return state;
    }
}

module.exports = resetPassword;